Telegram Group & Telegram Channel
127. Program for infix to postfix conversion.

#include<stdio.h>
char ifix[200],pfix[200],stack[100];
int p=0,s=0,i=0;
void fun()
{
if(ifix[i]==')')
{
s--;
while(stack[s]!='(')
pfix[p++]=stack[s--];
}
if(ifix[i]=='+' || ifix[i]=='-')
{
if(!s)
stack[s++]=ifix[i];
else if(stack[s-1]=='(')
stack[s++]=ifix[i];
else
{
s--;
while(s!=-1 && stack[s]!='(')
{
pfix[p++]=stack[s--];
}
stack[++s]=ifix[i];
s++;
}
}
}
int main()
{
printf("Enter your infix expression(using operators +, -, %%, /, *) : ");
scanf("%s",ifix);
for(i;ifix[i]!='\0';i++)
{
if(ifix[i]!='*' && ifix[i]!='/' && ifix[i]!='-' && ifix[i]!='+' && ifix[i]!='(' && ifix[i]!=')' && ifix[i]!='%')
pfix[p++]=ifix[i];
else if(ifix[i]=='(' || ifix[i]=='*' || ifix[i]=='/' || ifix[i]=='%')
stack[s++]=ifix[i];
else
fun();
}
if(ifix[i]=='\0')
{
if(s)
{
s--;
while(s!=-1)
{
if(stack[s]==')' || stack[s]=='(')
s--;
pfix[p++]=stack[s--];
}
}
pfix[p]='\0';
}
printf("The postfix expression is : %s",pfix);
return 0;
}
//used by taking into considering operators +, -, /, *, %, (, )
#program_by : @sidg28



tg-me.com/C_Codings/183
Create:
Last Update:

127. Program for infix to postfix conversion.

#include<stdio.h>
char ifix[200],pfix[200],stack[100];
int p=0,s=0,i=0;
void fun()
{
if(ifix[i]==')')
{
s--;
while(stack[s]!='(')
pfix[p++]=stack[s--];
}
if(ifix[i]=='+' || ifix[i]=='-')
{
if(!s)
stack[s++]=ifix[i];
else if(stack[s-1]=='(')
stack[s++]=ifix[i];
else
{
s--;
while(s!=-1 && stack[s]!='(')
{
pfix[p++]=stack[s--];
}
stack[++s]=ifix[i];
s++;
}
}
}
int main()
{
printf("Enter your infix expression(using operators +, -, %%, /, *) : ");
scanf("%s",ifix);
for(i;ifix[i]!='\0';i++)
{
if(ifix[i]!='*' && ifix[i]!='/' && ifix[i]!='-' && ifix[i]!='+' && ifix[i]!='(' && ifix[i]!=')' && ifix[i]!='%')
pfix[p++]=ifix[i];
else if(ifix[i]=='(' || ifix[i]=='*' || ifix[i]=='/' || ifix[i]=='%')
stack[s++]=ifix[i];
else
fun();
}
if(ifix[i]=='\0')
{
if(s)
{
s--;
while(s!=-1)
{
if(stack[s]==')' || stack[s]=='(')
s--;
pfix[p++]=stack[s--];
}
}
pfix[p]='\0';
}
printf("The postfix expression is : %s",pfix);
return 0;
}
//used by taking into considering operators +, -, /, *, %, (, )
#program_by : @sidg28

BY C Language πŸ‘¨β€πŸ’»


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/C_Codings/183

View MORE
Open in Telegram


C Language ‍ Telegram | DID YOU KNOW?

Date: |

The global forecast for the Asian markets is murky following recent volatility, with crude oil prices providing support in what has been an otherwise tough month. The European markets were down and the U.S. bourses were mixed and flat and the Asian markets figure to split the difference.The TSE finished modestly lower on Friday following losses from the financial shares and property stocks.For the day, the index sank 15.09 points or 0.49 percent to finish at 3,061.35 after trading between 3,057.84 and 3,089.78. Volume was 1.39 billion shares worth 1.30 billion Singapore dollars. There were 285 decliners and 184 gainers.

Mr. Durov launched Telegram in late 2013 with his brother, Nikolai, just months before he was pushed out of VK, the Russian social-media platform he founded. Mr. Durov pitched his new appβ€”funded with the proceeds from the VK saleβ€”less as a business than as a way for people to send messages while avoiding government surveillance and censorship.

C Language ‍ from in


Telegram C Language πŸ‘¨β€πŸ’»
FROM USA